#ifndef FILETRANSFERDIALOG_H
#define FILETRANSFERDIALOG_H

#include <QDialog>
#include <QTcpSocket>
#include <QFile>
#include <QProgressBar>
#include <QPushButton>
#include <QLabel>
#include "ui_filetransferdialog.h"

class FileTransferDialog : public QDialog
{
    Q_OBJECT

public:
    FileTransferDialog(QWidget *parent = nullptr);
    ~FileTransferDialog();

private slots:
    void onUploadButtonClicked();
    void onDownloadButtonClicked();
    void onPauseButtonClicked();
    void onResumeButtonClicked();
    void onCancelButtonClicked();
    void onSocketReadyRead();
    void onSocketBytesWritten(qint64 bytes);
    void updateProgress(qint64 bytesTransferred);

    void on_add_clicked();

    void on_start_clicked();

    void on_clear_clicked();

    void on_onUpload_clicked();

private:
    Ui::FileTransferDialog *ui;
    QTcpSocket *socket;
    QFile *file;
    QProgressBar *progressBar;
    QPushButton *uploadButton;
    QPushButton *downloadButton;
    QPushButton *pauseButton;
    QPushButton *resumeButton;
    QPushButton *cancelButton;
    QLabel *statusLabel;

    qint64 totalBytes;
    qint64 bytesTransferred;
    qint64 bytesToWrite;
    qint64 payloadSize;
    bool isPaused;
    bool isUploading;
};

#endif // FILETRANSFERDIALOG_H
